<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/resources/js/jquery-1.11.1.min.js"></script>
    <script src="/resources/js/self.js"></script>
    <script type="text/javascript" src="/resources/common/js/md5.js"></script>
    <script type="text/javascript" src="/resources/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="/resources/js/ajaxfileupload.js"></script>
    <script type="text/javascript" src="/resources/js/Util.js"></script>
</head>
<body>
<div class="row">
    <div class="col-md-12 col-sm-12 col-xs-12">
        <div class="x_panel">
            <div class="x_title">
                <h2>企业 <small>维护</small></h2>
                <ul class="nav navbar-right panel_toolbox">
                    <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                    </li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                        <ul class="dropdown-menu" role="menu">
                            <li><a href="#">Settings 1</a>
                            </li>
                            <li><a href="#">Settings 2</a>
                            </li>
                        </ul>
                    </li>
                    <li><a class="close-link"><i class="fa fa-close"></i></a>
                    </li>
                </ul>
                <div class="clearfix"></div>
            </div>
            <div class="x_content">
                <br>
                <div id="demo-form2"  class="form-horizontal form-label-left" >
                    <input type="hidden" name="id" class="form-data" >
                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="oldPassword">旧密码
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input type="password" id="oldPassword" name="oldPassword"
                                   class="form-control form-data col-md-7 col-xs-12" >
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="newPassword">新密码
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input type="password" id="newPassword" name="newPassword"
                                   class="form-control form-data col-md-7 col-xs-12">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="newPassword2">确认新密码
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input type="password" id="newPassword2" name="newPassword2"
                                   class="form-control form-data col-md-7 col-xs-12">
                        </div>
                    </div>
                    <div class="ln_solid"></div>
                    <div class="form-group">
                        <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">

                            <button onclick="save()" class="btn btn-success">提交</button>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    $(function () {
    });
    function save() {
        var params = getPageDataByClass("form-data");
        if (strIsNull(params['oldPassword'])) {
            alert("请输入老密码");
            return;
        }
        if (strIsNull(params['newPassword'])) {
            alert("请输入新密码");
            return;
        }
        if (strIsNull(params['newPassword2'])) {
            alert("请输入确认新密码");
            return;
        }
        if(params['newPassword'] !=params['newPassword2']){
            alert("两次密码不一致!");
            return;
        }
        params['oldPassword'] =  hex_md5(params['oldPassword'] );
        params['newPassword'] =  hex_md5(params['newPassword'] );
        $.ajax({
            url: "/admin/updatePassword.do",
            data: params,
            dataType: 'json',
            type: 'post',
            success: function (data) {
                console.log(data);
                if (data.success) {
                    alert("保存成功");
                } else {
                    alert(data.msg);
                }
            }
        });
    }

</script>
</html>